﻿using Microsoft.EntityFrameworkCore;
using PHMEE.Entities.DaqInfo.TdDevices;
using PHMEE.EntityFrameworkCore;
using PHMEE.IRepositories.DaqInfo.TdDevices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;

namespace PHMEE.Repositories.DaqInfo.TdDevices
{
    /// <summary>
    /// 超级表（设备类型）
    /// </summary>
    public class TdDeviceTypeRepository : EfCoreRepository<PHMEEDbContext, TdDeviceType, Guid>, ITdDeviceTypeRepository
    {
        public TdDeviceTypeRepository(IDbContextProvider<PHMEEDbContext> dbContextProvider) : base(dbContextProvider)
        {
        }
        /// <summary>
        /// 根据数据库id查询超级表
        /// </summary>
        /// <param name="databaseId"></param>
        /// <returns></returns>
        public async Task<List<TdDeviceType>> GetSuperByDataBaseTableIdAsync(Guid databaseId)
        {
            var dbContext = await GetDbContextAsync();
            return await dbContext.TdDeviceTypes
                .Where(st => st.DatabaseId == databaseId)
                .OrderBy(st => st.Name)
                .ToListAsync();
        }
    }
}
